package com.easylinkin.linkappapi.device.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.easylinkin.linkappapi.device.entity.ElectricyRecords;
import com.easylinkin.linkappapi.device.entity.vo.ElectricyRecordsVo;
import com.easylinkin.linkappapi.device.entity.vo.ElectricyStatisticsVo;
import com.easylinkin.linkappapi.openapi.dto.DatapushDTO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用电记录 服务类
 * </p>
 *
 * @author Xiaoyang
 * @since 2022-08-03
 */
public interface ElectricyRecordsService extends IService<ElectricyRecords> {

  /**
   * 新增
   *
   * @param electricyRecords 实体对象
   * @return 操作结果
   */
  boolean saveOne(ElectricyRecords electricyRecords);

  /**
   * 修改单条
   *
   * @param electricyRecords 实体对象
   * @return 修改结果
   */
  boolean updateOne(ElectricyRecords electricyRecords);

  /**
   * 查询分页
   *
   * @param page        分页对象
   * @param electricyRecords 分页参数对象
   * @return 查询分页结果
   */
  IPage<ElectricyRecords> selectPage(Page page, ElectricyRecordsVo electricyRecords);

  /**
   * 获取单条
   *
   * @param id 主键id
   * @return 查询结果
   */
  ElectricyRecords getOneById(Serializable id);

  /**
   * 根据id批量删除
   *
   * @param idList 主键列表
   * @return 删除结果
   */
  boolean deleteByIds(List<Long> idList);

  /**
   * 导出表格
   *
   * @param electricyRecords 过滤条件实体对象
   * @param request     请求
   * @param response    响应
   */
  void export(ElectricyRecordsVo electricyRecords, HttpServletRequest request, HttpServletResponse response);

  /**
   * 用电流水处理
   * @param datapushDTO
   */
  void datapushHandler(DatapushDTO datapushDTO);

  /**
   * 获取用电量统计数据
   * @param electricyRecordsVo
   * @return
   */
   ElectricyStatisticsVo getElectricyStatistics(ElectricyRecordsVo electricyRecordsVo);

  /**
   * 根据时间粒度查询用电量趋势统计数据
   * @param electricyRecordsVo
   * @return
   */
   List<ElectricyStatisticsVo> getElectricyStatisticsList(ElectricyRecordsVo electricyRecordsVo);

  /**
   * 根据年份统计今年每月用电量
   * @param electricyRecordsVo
   * @return
   */
   List<Map<String, Object>> electricyByYear(ElectricyRecordsVo electricyRecordsVo);

    /**
     * 逐日或者逐月进行统计,返回树状图{x:[],y[],unit:kwh}
     * @param electricyRecordsVo
     * @return
     */
   Map<String, Object> electricyByDayAndHour(ElectricyRecordsVo electricyRecordsVo);

    List<ElectricyRecords> codeByNewRecords(String tenantId,List<String> codes);

    /**
     * 获取当前租户下最早的一条记录
     * @return
     */
    ElectricyRecords getStartRecord();
}
